/**
 * 
 * @param {*} key 
 * @param {*} value 
 * @param {*} expires 
 */
function setCookie(key, value, expires) {
    if (expires) {
        let oDate = new Date();
        oDate.setDate(oDate.getDate() + expires);
        document.cookie = `${key}=${value};expires=${oDate}`;
      } else {
        document.cookie = `${key}=${value}`;
      }
  }


  function getCookie(key) {
    let str = document.cookie;
    let arr = str.split(";");
    let value;
    /* str.forEach(item => {
      // console.log(item);
      let arr = item.split('=');
      if(arr[0] == "key"){
        value = arr[1]
      }
    });
    return value; */
    for (let i = 0; i < arr.length; i++) {
      let brr = arr[i].split("=");
      if (brr[0] === key) {
        return brr[1];
      }
    }
  }

  
  function removeCookie(key) {
    setCookie(key, 1, -1);
  }